package routers

import (
    `gitee.com/go-programming-tour-book/blog-service/internal/routers/api`
    `github.com/gin-gonic/gin`
)

func NewRouter() *gin.Engine {
    r := gin.New()
    r.Use(gin.Logger())
    r.Use(gin.Recovery())

    tag := api.NewTag()
    article := api.NewArticle()

    apiv1 := r.Group("/api/v1")
    {
        // 创建标签
        apiv1.POST("/tags", tag.Create)
        // 删除指定标签
        apiv1.DELETE("/tags/:id", tag.Delete)
        apiv1.PUT("/tags/:id", tag.Update)
        // 更新指定标签
        apiv1.PATCH("/tags/:id/state", tag.Update)
        // 更新指定标签
        apiv1.GET("/tags", tag.List)

        // 创建文章
        apiv1.POST("/articles", article.Create)
        // 删除指定文章
        apiv1.DELETE("/articles", article.Delete)
        apiv1.PUT("/articles", article.Update)
        apiv1.PATCH("/articles", article.Update)
        // 获取文章列表
        apiv1.GET("/articles", article.List)
    }

    return r
}
